<%@ page import="java.sql.*" %>

<pre>
<%
	final javax.servlet.jsp.JspWriter finalOut = out;

	final class RSDumper
	{
	    public void dump(java.sql.ResultSet rs) throws java.io.IOException
	    {
	        try
	        {
	            final int numCols = rs.getMetaData().getColumnCount();

	            while (rs.next())
	            {
	                for (int i = 1; i<= numCols; i++)
	                {
	                    // output just enough to prove we are getting the rows
	                    String dbValue = rs.getString(i);
	                    String output = dbValue == null ? "" : (dbValue.startsWith("x") ? dbValue.substring(0, 1) + ' ' : dbValue + ' ');
	                    finalOut.print(output + "\t");
	                }
	                finalOut.println("");
	            }
	            finalOut.println("");
	        }
	        catch (java.sql.SQLException e)
	        {
	        	finalOut.println("SQLException dumping result set: " + e);
	        }
	    }
	}
	
	RSDumper dumper = new RSDumper();

	  // Create a variable for the connection string.
      String connectionUrl = "jdbc:jtds:sqlserver://av1dyu6dne.database.windows.net:1433/imgbms;ssl=require"; 
      
      // Declare the JDBC objects.
      Connection con = null;
      Statement stmt = null;
      ResultSet rs = null;

      try {
         // Establish the connection.
         Class.forName("net.sourceforge.jtds.jdbc.Driver");
         con = DriverManager.getConnection(connectionUrl, "eamr@av1dyu6dne", "e@mr2011");

         // Create and execute an SQL statement that returns some data.
         String SQL = "SELECT TOP 10 * FROM dbo.Contact";
         stmt = con.createStatement();
         rs = stmt.executeQuery(SQL);

         // Iterate through the data in the result set and display it.
         dumper.dump(rs);
      }
      finally {
         if (rs != null) try { rs.close(); } catch(Exception e) {}
         if (stmt != null) try { stmt.close(); } catch(Exception e) {}
         if (con != null) try { con.close(); } catch(Exception e) {}
      }
%>
</pre>